package com.ushio.gougouwangguo.service.impl;

import com.ushio.commonmodule.pojo.user.User;
import com.ushio.commonmodule.pojo.vo.SeasonEventVo;
import com.ushio.commonmodule.pojo.vo.UserSeasonEventVo;
import com.ushio.commonmodule.utils.JwtUtil;
import com.ushio.gougouwangguo.entity.mysql.SeasonEvent;
import com.ushio.gougouwangguo.entity.mysql.UserSeasonEvent;
import com.ushio.gougouwangguo.mapper.SeasonEventMapper;
import com.ushio.gougouwangguo.mapper.UserSeasonEventMapper;
import com.ushio.gougouwangguo.service.ISeasonEventService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 季节特殊事件表 服务实现类
 * </p>
 *
 * @author 张文凯
 * @since 2025-09-23
 */
@Service
public class SeasonEventServiceImpl extends ServiceImpl<SeasonEventMapper, SeasonEvent> implements ISeasonEventService {

    @Autowired
    UserSeasonEventMapper userSeasonEventMapper;
    @Override
    public UserSeasonEventVo initializeSeasonEvent(User user) {

        if (user.getUserId()==null){
            throw new RuntimeException("userId不能为空");
        }

        Long userId = user.getUserId();

        UserSeasonEvent userSeasonEvent = UserSeasonEvent.builder().userId(userId).seasonEventId(1).build();

        userSeasonEventMapper.insert(userSeasonEvent);

        UserSeasonEventVo userSeasonEventVo = UserSeasonEventVo.builder().build();

        BeanUtils.copyProperties(userSeasonEvent,userSeasonEventVo);

        return userSeasonEventVo;
    }
}
